<html>
<head>
  <meta content="text/plain" charset="utf-8" />
  <script src="script/jquery-2.1.4.min.js"></script>
  <script>

  var LinvoDB = require("linvodb3");

// The following two lines are very important
// Initialize the default store to Medeadown - which is a JS-only store which will work without recompiling in NW.js / Electron
LinvoDB.defaults.store = { db: require("medeadown") }; // Comment out to use LevelDB instead of Medea
// Set dbPath - this should be done explicitly and will be the dir where each model's store is saved
LinvoDB.dbPath = process.cwd();
alert(LinvoDB.dbPath);
alert(LinvoDB.defaults);

var DocTable = new LinvoDB("DocTable");

var doc1 = new DocTable({col1:123, col2:"4556", now:new Date()});

DocTable.insert(doc1, function(err, newDoc){
  console.log("newDoc._id=" + newDoc._id);
});

function query(queryVal) {
  DocTable.find({col1:parseInt(queryVal)}, function(err, queryDocs) {
    console.log(queryDocs);
    $("#result_ul").empty();
    for (var i=0; i < queryDocs.length; i++) {
      var doc = queryDocs[i];
      $("#result_ul").append("<li>" + doc._id + "  ||  " + doc.col1 + "  ||  " + doc.col2 + "  ||  " + doc.now + "</li>");
    }
  });
}


  </script>
</head>
<body>
  <input type="text" id='query_col1' name="name" value="" />
  <input type="button" name="query_button" value="查询" onclick="query($('#query_col1').val())" />

  <ul id="result_ul">

  </ul>
</body>
</html>
